강의에서 보여주신 코드를 그대로 사용했을 때에는 com.DefaultCompany.MyFirstGame를 찾을 수 없다며 연결이 안 된다고 해서 PID를 찾아 attach 하는 방식으로 코드를 바꾸어 사용하니 연결까지는 되었습니다. 그런데 이제 libil2cpp.so라는 모듈을 찾을 수가 없다고 하네요... com.DefaultCompany.MyFirstGame/lib/ 밑에 보면 libil2cpp.so가 제대로 있는데 왜 이런 모듈이 없다고 하는 것일까요? 구글링 해보니 라이브러리가 로드되기 전에 이 과정을 수행해서 문제가 되는 것 같다고 하는 분도 계셔서 라이브러리가 로드된 뒤에 강의의 코드를 수행하도록 수정도 해봤습니다. 그러나 "[*] Running Frida"까지만 출력되고, 그 외에 어떠한 동작도 하지 않네요... 그리고 게임 화면이 까맣게 변해 동작하지 않게 됩니다.이런 문제는 어떻게 해결할 수 있을까요? 프리다와 프리다 서버 버전은 16.0.2입니다. 수정한 코드 첨부하겠습니다.import sys
import frida
PACKAGE_NAME = "com.DefaultCompany.MyFirstGame"
def on_message(message, data):
print(message)
jscode = """
var library_name = "libil2cpp.so";
var library_loaded = 0;
Interceptor.attach(Module.findExportByName(null, 'android_dlopen_ext'),{
onEnter: function(args){
// first arg is the path to the library loaded
var library_path = Memory.readCString(args[0]);
if( library_path.includes(library_name)){
console.log("[...] Loading library : " + library_path);
library_loaded = 1;
}
},
onLeave: function(args){
// if it's the library we want to hook, hooking it
if(library_loaded == 1){
console.log("[+] Loaded");
var il2cpp = Module.getBaseAddress("libil2cpp.so");
var spend_gold = il2cpp.add(0x59552C);
console.log(hexdump(spend_gold));
Memory.protect(spend_gold, 0x8, "rwx");
Memory.writeByteArray(spend_gold, [0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1]);
console.log(hexdump(spend_gold));
library_loaded = 0;
}
}
})
"""
try:
device = frida.get_usb_device()
pid = device.spawn(['com.DefaultCompany.MyFirstGame'])
process = device.attach(pid)
script = process.create_script(jscode)
print('[*] Running Frida')
script.on('message', on_message)
script.load()
sys.stdin.read()
except Exception as e:
print(e)